// BaseLex.h: interface for the BaseLex class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_BASELEX_H__92D44C60_792F_11D2_8062_00A0C91F41A7__INCLUDED_)
#define AFX_BASELEX_H__92D44C60_792F_11D2_8062_00A0C91F41A7__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "constants.h"
#include "MyException.h"

class BaseLex  : public CMyException
{
public:
	BaseLex();
    BaseLex(char *);
	virtual ~BaseLex();

    // Implementation
public:
	char * Read(FILE *m_hInfile);
    // do the initialization crap
    void    Init();                
    // make baselex to parse the string contained in str
    void    SetBuffer(char *str)  
    { 
        if(str!=m_szBuffer) 
        { 
            strcpy(m_szBuffer,str); 
            m_pStr = m_szBuffer;
        }
    }
    // get the string that is being parsed
    inline  char * GetBuffer(void) { return m_szBuffer; }

    // get the position where parsing last stopped
    char *GetUnparsedString(void) { return m_pStr; }
    inline  int GetBufferLen()    { return BUFSIZE; }
    inline  char * GetToken(void) { return &(m_szToken[0]); }
    virtual int NextToken();
    virtual int Advance();

    virtual CString GetErrorPrefix();


    // function which throws the exception
    virtual void ThrowException(severity s,the_exceptions e, const CString& str);
    
protected:
	char    m_szBuffer[BUFSIZE+1];	// this will hold the string to be parsed
	char	*m_pStr;                // current position in the parsed string
	int		m_nToken;               // integer value of the token parsed 
    char    m_szToken[BUFSIZE+1];   // the last token that was parsed
    CString m_szErrorPrefix;        // the error string filled by GetErrorPrefix
};

#endif // !defined(AFX_BASELEX_H__92D44C60_792F_11D2_8062_00A0C91F41A7__INCLUDED_)
